<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of class
 *
 * @author ww
 */
class SimpleTaskFormThree extends ATaskForm {

    public function getFormHTML($params, $view) {
        return $view->getCustomer_formbody_step3_execution($params);
    }

    public function validate_form(&$param, &$scope, $manager) {
        $iserror = false;
        //VTIME
        if (empty($param['lifetime'])) {
            $iserror = true;
            $manager->addErorrMessageForField("lifetime", "Время не задано");
        } elseif (!in_array(intval($param['lifetime']), array(30, 60, 120))) {
            $iserror = true;
            $manager->addErorrMessageForField("lifetime", "Время указано неверно");
        }
        else
            $param['lifetime'] = intval($param['lifetime']);

        if ($iserror) {
            return array_merge(array(VALIDATION_FAILED));
        }
        return array_merge(array(VALIDATION_ACCEPTED));
    }

    public function submit_form($data, $scope, $manager) {
        $typeoftask = $manager->getSessionVariable('task_type');
        $manager->saveDataInToSession($data, TaskFormHelper::STEP3_FORM_NAME . '_' . $typeoftask);
        redirect(DIR_BASE . "task/add/step4");   
    }

}
?>
